package Include;

import Common.SymbolType;
import Common.Type;

import java.util.List;

public class Symbol {
    public String name;
    public Scope scope;
    public SymbolType symbol_type;
    public Type type;
    public List<Type> fun_ret_type_list;
    public List<Type> fun_para_type_list;
    public boolean is_array;
    public int array_length;

    public Symbol(String name, Scope scope, SymbolType symbol_type, Type type,
           List<Type> fun_ret_type_list, List<Type> fun_para_type_list, boolean is_array, int array_length) {
        this.name = name;
        this.scope = scope;
        this.symbol_type = symbol_type;
        this.type = type;
        this.fun_ret_type_list = fun_ret_type_list;
        this.fun_para_type_list = fun_para_type_list;
        this.is_array = is_array;
        this.array_length = array_length;
    }

    public Symbol(String name, Scope scope, SymbolType symbol_type, Type type) {
        this.name = name;
        this.scope = scope;
        this.symbol_type = symbol_type;
        this.type = type;
        this.fun_ret_type_list = null;
        this.fun_para_type_list = null;
        this.is_array = false;
        this.array_length = 0;
    }

    public boolean isVar() {
        return this.symbol_type == SymbolType.VAR;
    }

    public boolean isFun() {
        return this.symbol_type == SymbolType.FUN;
    }

    public static Type toType(String s) {
        if (s.equals("int")) return Type.INT;
        return null;
    }
}
